//
//  OrderOneTableViewCell.m
//  KindergartenDemo
//
//  Created by 李传铎 on 2020/11/8.
//  Copyright © 2020 李传铎. All rights reserved.
//

#import "OrderOneTableViewCell.h"

@implementation OrderOneTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        [self createUI];
        [self layoutUI];
    }
    return self;
}

- (void)createUI {
    [self.contentView addSubview:self.userImageV];
    [self.contentView addSubview:self.stateL];
    [self.contentView addSubview:self.userNameL];
    [self.contentView addSubview:self.line1V];
    [self.contentView addSubview:self.mainImageV];
    [self.contentView addSubview:self.titleL];
    [self.contentView addSubview:self.detailsL];
    [self.contentView addSubview:self.amountL];
    [self.contentView addSubview:self.countL];
    [self.contentView addSubview:self.lineV];
    [self.contentView addSubview:self.customerBtn];
    [self.contentView addSubview:self.cancelBtn];
    
}

- (void)layoutUI {
    
    
    [self.userImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
    
    [self.stateL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.userImageV.mas_centerY);
    }];
    
    [self.userNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.userImageV.mas_right).offset(5);
        make.centerY.mas_equalTo(self.userImageV.mas_centerY);
        make.right.mas_equalTo(self.stateL.mas_left).offset(-5);
    }];
    
    [self.line1V mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.userImageV.mas_bottom).offset(10);
        make.height.mas_equalTo(1);
    }];
    
    [self.mainImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(self.line1V.mas_bottom).offset(10);
        make.width.mas_equalTo(95);
        make.height.mas_equalTo(95);
    }];
    
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mainImageV.mas_right).offset(10);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.mainImageV.mas_top).offset(5);
        
    }];
    
    [self.detailsL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mainImageV.mas_right).offset(10);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.titleL.mas_bottom).offset(10);
       
    }];
    
    [self.amountL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.mainImageV.mas_bottom).offset(-5);
        make.left.mas_equalTo(self.mainImageV.mas_right).offset(10);
        
    }];
    
    [self.countL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.amountL.mas_centerY);
        make.right.mas_equalTo(-15);
        
    }];
    
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.mainImageV.mas_bottom).offset(10);
        make.height.mas_equalTo(1);
    }];
    
    [self.customerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.lineV.mas_bottom).offset(10);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(30);
        make.bottom.mas_equalTo(-15);
    }];
    
    [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.customerBtn.mas_left).offset(-15);
        make.top.mas_equalTo(self.lineV.mas_bottom).offset(10);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(30);
    }];
    
    
   
}
- (UIImageView *)userImageV{
    if (!_userImageV) {
        _userImageV = [UIImageView new];
        _userImageV.image = imageNameStr(@"ic_avator");
    }
    return _userImageV;
}
- (UILabel *)userNameL{
    if (!_userNameL) {
        _userNameL = [UILabel new];
        _userNameL.text = @"用户名字";
        _userNameL.textColor = colorCode(@"#323A5A");
        _userNameL.font = fontCount(14);
    }
    return _userNameL;
}
- (UILabel *)stateL{
    if (!_stateL) {
        _stateL = [UILabel new];
        _stateL.textAlignment = NSTextAlignmentRight;
        _stateL.text = @"待使用";
        _stateL.textColor = colorCode(@"#F34B4D");
        _stateL.font = fontCount(16);
    }
    return _stateL;
}
- (UIView *)line1V{
    if (!_line1V) {
        _line1V = [UIView new];
        _line1V.backgroundColor = colorCode(@"#E6E6E6");
    }
    return _line1V;
}
- (UIImageView *)mainImageV{
    if (!_mainImageV) {
        _mainImageV = [UIImageView new];
        _mainImageV.image = imageNameStr(@"pic_holder_pic");
    }
    return _mainImageV;
}
- (UILabel *)titleL{
    if (!_titleL) {
        _titleL = [UILabel new];
        _titleL.text = @"3-6岁儿童手工课第35期暑假特惠班,共35课时";
        _titleL.numberOfLines = 2;
        _titleL.textColor = colorCode(@"#323A5A");
        _titleL.font = fontCount(14);
    }
    return _titleL;
}
- (UILabel *)detailsL{
    if (!_detailsL) {
        _detailsL = [UILabel new];
        _detailsL.text = @"实付：¥2000.00";
        _detailsL.numberOfLines = 2;
        _detailsL.textColor = colorCode(@"#84899D");
        _detailsL.font = fontCount(12);
    }
    return _detailsL;
}
- (UILabel *)amountL{
    if (!_amountL) {
        _amountL = [UILabel new];
        _amountL.text = @"¥2000.00";
        _amountL.textColor = colorCode(@"#F34B4D");
        _amountL.font = fontCount(18);
    }
    return _amountL;
}
- (UILabel *)countL{
    if (!_countL) {
        _countL = [UILabel new];
        _countL.text = @"x1";
        _countL.textColor = colorCode(@"#84899D");
        _countL.font = fontCount(14);
    }
    return _countL;
}
- (UIView *)lineV{
    if (!_lineV) {
        _lineV = [UIView new];
        
    }
    _lineV.backgroundColor = colorCode(@"#E6E6E6");
    return _lineV;
}
- (UIButton *)cancelBtn{
    if (!_cancelBtn) {
        _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cancelBtn setTitle:@"取消订单" forState:0];
        _cancelBtn.titleLabel.font = fontCount(14);
        [_cancelBtn setTitleColor:colorCode(@"999999") forState:0];
        _cancelBtn.layer.borderColor = colorCode(@"#979797").CGColor;
        _cancelBtn.layer.cornerRadius = 16;
        _cancelBtn.layer.borderWidth = 1;
    }
    
    return _cancelBtn;
}
- (UIButton *)customerBtn{
    if (!_customerBtn) {
        _customerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_customerBtn setTitle:@"联系客户" forState:0];
        _customerBtn.titleLabel.font = fontCount(14);
        [_customerBtn setTitleColor:colorCode(@"ffffff") forState:0];
        [_customerBtn setBackgroundColor:colorCode(@"#FE7778")];
        _customerBtn.layer.cornerRadius = 16;
        _customerBtn.layer.masksToBounds = YES;
    }
    return _customerBtn;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
